class code2 {
    //仅仅反转字母:双指针+判断Character.isLetter
    public String reverseOnlyLetters(String s) {
        int left = 0;
        int right = s.length()-1;
        char[] ss = s.toCharArray();

        while(left<right) {
            while(left<right && (!Character.isLetter(ss[left]))) left++;
            while(left<right && (!Character.isLetter(ss[right]))) right--;

            if(left<right) {
                char tmp = ss[left];
                ss[left++] = ss[right];
                ss[right--] = tmp;
            }
        }
        return new String(ss);
    }

}